package yang.yu.hrm.organisation.domain;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by yyang on 2016/10/7.
 */
@Entity
@Inheritance
public abstract class Organization extends AbstractEntity {

    private String name;

    @ManyToOne
    private Organization parent;

    @OneToMany(mappedBy = "parent")
    private List<Organization> children = new ArrayList<>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Organization getParent() {
        return parent;
    }

    public void setParent(Organization parent) {
        this.parent = parent;
    }

    public List<Organization> getChildren() {
        return children;
    }

    public void setChildren(List<Organization> children) {
        this.children = children;
    }

    public abstract void createChild(Organization org);
}
